package com.example.smart_community.controller;

import com.example.smart_community.po.Staff;
import com.example.smart_community.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/staff")
public class StaffController {
    @Autowired
    private StaffService staffService;
    @GetMapping("/selectByPostId")
    public List<Staff> selectByPostId(){
        return staffService.selectByPostId(104);
    }
    @GetMapping("/selectByDynamic")
    public List<Staff> selectByDynamic(String name,Integer postId,String entryTime1,String entryTime2,String address){
        return staffService.selectByDynamic(name, postId, entryTime1, entryTime2, address);
    }
    @GetMapping("/updateByDynamic")
    public  int updateByDynamic( Integer sId,String name,String gender,String entryTime, Integer status,String phone,String address,String idcard, Integer postId){
        return staffService.updateByDynamic(sId, name, gender, entryTime, status, phone, address, idcard, postId);
    }
    @GetMapping("/insertStaff")
    public int insertStaff(String name,String gender,String entryTime, String phone,String address,String idcard,Integer postId){
        return staffService.insertStaff(name, gender, entryTime, 1, phone, address, idcard, postId, 1);
    }
    @GetMapping("/updateByState")
    public int updateByState(Integer sId,Integer state){
        return staffService.updateByState(sId, state);
    }

}
